package com.example.kotlin.ui

import android.os.Bundle
import android.os.Environment
import androidx.appcompat.app.AppCompatActivity
import com.example.kotlin.R
import kotlinx.coroutines.MainScope
import java.io.File

class Main2Activity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main2)
        MainScope()
        val with: Int = with("222") {
            this.length
        }
        "ww".let {
            it.length
        }
        val a = arrayOf("2")
        val path = Environment.getExternalStorageDirectory().path
//        val listFiles: Array<File> = File(path).listFiles()
//        listFiles.forEach {
//            println(it)
//        }

        val map: Map<Char, List<Char>> = File(path, "筋斗云.txt")
            .readText()
            .toCharArray()
            .filterNot { it.isWhitespace() }
            .groupBy { it }
      //  println(map)
        // .map { it.key to it.value.size }

        val also: String = "222".also {
            it.length
        }


        val apply: String = "11".apply {
            this.length
        }
        "111"?.run {
            this.length
        }
    }
}
